#!/bin/sh

cat /etc/apt/sources.list
sed -i 's|ftp.debian.org|mirrors.ustc.edu.cn|g' /etc/apt/sources.list
sed -i 's|security.debian.org|mirrors.ustc.edu.cn/debian-security|g' /etc/apt/sources.list
echo "deb http://download.proxmox.com/debian/pve bullseye pve-no-subscription" >> /etc/apt/sources.list
mv /etc/apt/sources.list.d/pve-enterprise.list /etc/apt/sources.list.d/pve-enterprise.list.bak
apt-get update
pveceph install
pveceph init --network 192.168.100.129/24
cat /etc/pve/ceph.conf
pveceph createmon

# ========================
# 必须是 root 用户

/etc/hosts
192.168.100.128 ceph1
192.168.100.129 ceph2
192.168.100.130 ceph3

sudo apt-get update && sudo apt-get install ceph cephadm
sudo ./cephadm bootstrap --mon-ip 127.0.0.1

ssh-copy-id -f -i /etc/ceph/ceph.pub ceph2
ssh-copy-id -f -i /etc/ceph/ceph.pub ceph3

ceph orch host add ceph2
ceph orch host add ceph3

# 稍等一会

ceph mgr services

# ceph orch daemon add osd ceph1:/dev/sdb
ceph orch daemon add osd ceph2:/dev/sdb
ceph orch daemon add osd ceph2:/dev/sdc
ceph orch daemon add osd ceph3:/dev/sdb

# clock skew detected on mon.ceph3


# ========================

DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
mkdir -p $DOCKER_CONFIG/cli-plugins
curl -SL https://github.com/docker/compose/releases/download/v2.19.1/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose
ln -s $DOCKER_CONFIG/cli-plugins/docker-compose /usr/local/bin/docker-compose

wget https://github.com/goharbor/harbor/releases/download/v2.8.2/harbor-offline-installer-v2.8.2.tgz
cd harbor
cp -v harbor.yml.tmpl harbor.yml
./prepare
./install.sh

# ========================

sudo docker run -d --restart=unless-stopped --name=kuboard -p 80:80/tcp -p 10081:10081/tcp -e KUBOARD_ENDPOINT="http://内网IP:80" -e KUBOARD_AGENT_SERVER_TCP_PORT="10081" -v /root/kuboard-data:/data eipwork/kuboard:v3

# ========================
lspci -nnk | grep NVI
qm set 106 -hostpci0 01:00.0
